function Node(val) {
    this.value = val;
    this.left = null;
    this.right = null;
}

const a1 = new Node('a');
const b1 = new Node('b');
const c1 = new Node('c');
const d1 = new Node('d');
const e1 = new Node('e');
const f1 = new Node('f');
const g1 = new Node('g');
const h1 = new Node('h');

a1.left = b1;
a1.right = c1;
b1.left = d1;
b1.right = e1;
c1.left = f1;
c1.right = g1;
e1.left = h1;

const a2 = new Node('a');
const b2 = new Node('b');
const c2 = new Node('c');
const d2 = new Node('d');
const e2 = new Node('e');
const f2 = new Node('f');
const g2 = new Node('g');
const h2 = new Node('h');

a2.left = b2;
a2.right = c2;
b2.left = d2;
b2.right = e2;
c2.left = f2;
c2.right = g2;
e2.left = h2;

function diffTree(root1, root2, list) {
    if (root1 == root2) return list;
    if (root1 == null && root2 != null) {
        list.push({
            type: "新增",
            origin: null,
            now: root2
        });
    } else if (root1 != null && root2 == null) {
        list.push({
            type: "删除",
            origin: root1,
            now: null
        });
    } else if (root1.value != root2.value) {
        list.push({
            type: "修改",
            origin: root1,
            now: root2
        });
    } else {
        diffTree(root1.left, root2.left, list);
        diffTree(root1.right, root2.right, list);
    }
}
let listArr = [];
diffTree(a1, a2, listArr)
console.log(listArr);